<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:directive.page import="java.util.List" />
<jsp:directive.page import="java.util.Map" />

<%
List list = (List)request.getAttribute("list");
%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<title></title>
<script type="text/javascript" src="<%=basePath %>ui/js/rightsettree.js"></script>
<script type="text/javascript">
 function checkForm(){
   	var k=0;
    var compareList = form1.nodeId;
    for (var i = 0, c = compareList.length; i < c; ++i) {
        if (compareList[i].checked) {
            k++;
            if (k>0) break;
        }
    }
    if (k==0) {
        alert("请选择功能结点！");
        return false;
    }
    return true;
  }
</script>
</head>
<body
	style="_width:expression(this.parentNode.offsetHeight > this.parentNode.scrollHeight ? '100%' : parseInt(this.parentNode.clientWidth) + 'px');">


	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="8" height="8"></td>
			<td width="99%">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td></td>
					</tr>
				</table>
			</td>
			<td width="8" height="8"></td>
		</tr>
		<tr>
			<td></td>
			<td bgcolor="#FFFFFF" style="height:490px; vertical-align:top;">
				<form onsubmit="return checkForm()" name="form1"
					action="${basePath}role/rightSet/${porCode }.html">
					<table width="100%" border="0" cellspacing="10" cellpadding="0">
						<tr>
							<td></td>
						</tr>
						<tr>
							<td>
								<fieldset id="Dashed">
									<legend id="Title">角色权限设置</legend>

									<table width="700" border="0" align="center" cellpadding="0"
										cellspacing="5">

										<tr>
											<td width="50%" nowrap><script type="text/javascript">
										var rootTree = new WebFXTree('权限结点');
										<%
										
										String rootTree = "";
										for(int i=0;i<list.size();i++)
										{
										   Map node = (Map)list.get(i);  
										   String nodeCode = node.get("nodeCode").toString();
										   String nodeName = node.get("nodeName").toString();
										   String isflag = node.get("isHasSonNode").toString(); 
										   String roleId = "";
										   if(node.get("roleId")!=null)
										   	  roleId = node.get("roleId").toString();
										   String roleFlag;
										   if(roleId==null||roleId.equalsIgnoreCase(""))
										   		roleFlag = "0";
										   else
										       roleFlag = "1";
										   roleFlag = roleFlag + "," + isflag + "," + nodeCode;
										   if(isflag.equalsIgnoreCase("1")){
											     %>
											     var folder<%=nodeCode%>= new WebFXTreeItem('<%=nodeName%>','<%=roleFlag%>',null,null,true);
											    
											     rootTree.add(folder<%=nodeCode%>);
											     <%
										   }else{
											     String item = nodeCode.substring(0,nodeCode.length()-2);
											     %>
											      var item<%=nodeCode%>= new WebFXTreeItem('<%=nodeName%>',"<%=roleFlag%>");
											     folder<%=item%>.add(item<%=nodeCode%>);
											     <%
										   }
										}
										out.print(rootTree);
										%>
									
										
										 document.write(rootTree);
										 rootTree.expandAll();
										    </script></td>
											<td align="left" valign="top">请选中所需的权限结点<br> <input
												type="hidden" value="${id }" name="id"></td>
										</tr>

									</table>
								</fieldset>
							</td>
						</tr>
						<tr>
							<td align="center" valign="middle"><center>
									<input type="submit" class="input_ok" name="add" value=" 提 交 ">
									<input type="reset" class="input_ok" name="clear" value=" 重置 ">
									<input type="button" class="input_ok" name="clear"
										value=" 返 回 " onclick="window.history.back();">
								</center>&nbsp; <font color="#FFFFFF">.</font></td>
						</tr>
					</table>
				</form>
			</td>
			<td></td>
		</tr>
		<tr>
			<td width="8" height="8"></td>
			<td></td>
			<td width="8" height="8"></td>
		</tr>
	</table>
</body>
</html>